import React, { Component } from 'react'
import UserContext from './contexts/user-context';
import ThemeContext from './contexts/theme-context';

export class HomeInfo extends Component {
  render() {
    // 4. 获取数据并使用
    console.log(this.context);
    return (
      <>
      <div>UserContext:{this.context.message}</div>
      <ThemeContext.Consumer>
        {
          value => {
            return <div style={value}>ThemeContext</div>
          }
        }
      </ThemeContext.Consumer>
      </>
    )
  }
}

// 3.设置组件的contextType为某一个Context
HomeInfo.contextType = UserContext
export default HomeInfo